$file1 = "GPL3921.annot";
$file2 = "GPL96.annot";
$file3 = "GPL97.annot";
$file4 = "GPL570.annot";
open(BUFF1,$file1);
open(BUFF2,$file2);
open(BUFF3,$file3);
open(BUFF4,$file4);
open(BUFF5,$file4);
open(WRBUFF1,">common_genes_hthguA_hguA_plus2.txt");
open(WRBUFF2,">common_genes_hguB_plus2_notin1.txt");
open(WRBUFF3,">common_genes_hguA_hguB.txt");
$line = <BUFF1>;
$line = <BUFF2>;
$line = <BUFF3>;
$line = <BUFF4>;
$line = <BUFF5>;
$v = "///";
while($line = <BUFF1>)
{
	chomp $line;
	@array = split("\t",$line);
	$hash1{$array[0]} = "k";

}
while($line = <BUFF2>)
{
        chomp $line;
        @array = split("\t",$line);
	$hash2{$array[0]} = "k";

}
while($line = <BUFF4>)
{
        chomp $line;
        @array = split("\t",$line);
       @array_gene = split($v,$array[2]);
        if(scalar(@array_gene) <2 && $array[2] ne "")
        {
		if($hash2{$array[0]} eq  "k" && $hash1{$array[0]} eq "k")
		{
			print WRBUFF1 $array[2]."\t".$array[3]."\t".$array[9]."\n";
			 print WRBUFF3 $array[2]."\t".$array[3]."\t".$array[9]."\n";
			$hash3{$array[0]}  = "k";
		}
        }

}


while($line = <BUFF3>)
{
        chomp $line;
        @array = split("\t",$line);
        $hash4{$array[0]} = "k";

}
while($line = <BUFF5>)
{
        chomp $line;
        @array = split("\t",$line);
       @array_gene = split($v,$array[2]);
        if(scalar(@array_gene) <2 && $array[2] ne "")
        {
                if($hash4{$array[0]} eq  "k" && $hash3{$array[0]} ne "k")
                {
                        print WRBUFF2 $array[2]."\t".$array[3]."\t".$array[9]."\n";
			 print WRBUFF3 $array[2]."\t".$array[3]."\t".$array[9]."\n";
                }
        }

}
